﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Vds2465Telegrams
{
	public class UserData_01_Priority : UserData
	{
		#region private member variables

		private readonly byte _priorityReduction;
		
		#endregion private member variables

		#region constructor

		public UserData_01_Priority(byte priorityReduction) : base(UserData.UserData01Priority)
		{ 
			_priorityReduction = priorityReduction;
		}

		#endregion constructor

		#region getters

		/// <summary>
		/// 0xff lowest priority
		/// 0x00 highest priority
		/// </summary>
		public byte PriorityReduction { get { return _priorityReduction; } }

		#endregion getters

		#region ToString, Equals, GetHashCode

		public override int GetHashCode()
		{
			int hashCode = base.GetHashCode();
			hashCode ^= PriorityReduction;

			return hashCode;
		}

		public override string ToString()
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.Append("(");
			stringBuilder.Append(ToStringProperties());
			stringBuilder.Append(")");

			return stringBuilder.ToString();
		}

		internal override string ToStringProperties()
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.Append(base.ToStringProperties());
			stringBuilder.Append(", ");

			stringBuilder.Append("PriorityReduction='");
			stringBuilder.Append(PriorityReduction);
			stringBuilder.Append("'");
			return stringBuilder.ToString();
		}

		public override bool Equals(object obj)
		{
			Type objType = obj.GetType();
			if (this.GetType() == objType)
			{
				UserData_01_Priority userData01Priority2Compare = obj as UserData_01_Priority;
				return EqualsProperties(userData01Priority2Compare);
			}

			return false;
		}

		internal bool EqualsProperties(UserData_01_Priority userData01Priority2Compare)
		{
			if (base.EqualsProperties(userData01Priority2Compare))
			{
				return (PriorityReduction == userData01Priority2Compare.PriorityReduction);
			}

			return false;
		}		

		#endregion ToString, Equals, GetHashCode
	}
}
